home *** CD-ROM | disk | FTP | other *** search
/ NeXT Enterprise Objects Framework 1.1 / NeXT Enterprise Objects Framework 1.1.iso / NextDeveloper / Examples / EnterpriseObjects / SQLExecutor / ScrollViewExtras.m < prev    next >
Encoding:
Text File  |  1994-09-03  |  1.6 KB  |  83 lines

  1. /* ScrollViewExtras.m:
  2.  * You may freely copy, distribute, and reuse the code in this example.
  3.  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  4.  * fitness for any particular use.
  5.  *
  6.  * A generic scrollview driver object to display/print text 
  7.  * Written by Jack Greenfield
  8.  *
  9.  */
  10.  
  11. #import    <objc/objc-runtime.h>
  12. #import "ScrollViewExtras.h"
  13.  
  14. @implementation ScrollView(ScrollViewExtras)
  15.  
  16. - sprintf:(const char *)format, ...
  17. {
  18.     int length;
  19.     static char buffer[65536];
  20.     va_list arguments;
  21.  
  22.     if ([window isVisible])
  23.     {
  24.     va_start(arguments, format);
  25.     vsprintf(buffer, format, arguments);
  26.     va_end(arguments);
  27.     
  28.     length = [[self docView] textLength];
  29.     [[self docView] setSel:length :length];
  30.     [[self docView] replaceSel:buffer];
  31.     [[self docView] scrollSelToVisible];
  32.     }
  33.  
  34.     return self;
  35. }
  36.  
  37. - vsprintf:(const char *)format arguments:(va_list)arguments
  38. {
  39.     int length;
  40.     static char buffer[65536];
  41.  
  42.     if ([window isVisible])
  43.     {
  44.     vsprintf(buffer, format, arguments);
  45.     length = [[self docView] textLength];
  46.     [[self docView] setSel:length :length];
  47.     [[self docView] replaceSel:buffer];
  48.     [[self docView] scrollSelToVisible];
  49.     }
  50.  
  51.     return self;
  52. }
  53.  
  54. - clear:sender
  55. {
  56.     int length;
  57.  
  58.     if ([window isVisible])
  59.     {
  60.     length = [[self docView] textLength];
  61.     [[self docView] setSel:0 :length];
  62.     [[self docView] replaceSel:""];
  63.     [[self docView] scrollSelToVisible];
  64.     }
  65.  
  66.     return self;
  67. }
  68.  
  69. - print:sender
  70. {
  71.     if ([window isVisible])
  72.     [[self docView] printPSCode:sender];
  73.  
  74.     return self;
  75. }
  76.  
  77. - printFrom:sender
  78. {
  79.     return [self sprintf:"%s\n", [sender stringValue]];
  80. }
  81.  
  82. @end
  83.